<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Course/course_index',array('series_id'=>$series_id))}">课程管理</a></li>
			<li class="active"><a href="javascript:;">添加课程</a></li>
		</ul>
		<form action="" method="post" class="form-horizontal js-ajax-forms">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<tr>
							<th width="120">课程名称</th>
							<td>
								<input type="text" style="width: 400px;" name="title" id="title" value="" placeholder="请输入课程名称"/>
							</td>
						</tr>
						<tr>
							<th width="120">课程链接地址</th>
							<td>
								<input type="text" style="width: 400px;" name="video_url" id="video_url" value="" placeholder="请输入课程链接地址"/>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div class="form-actions">
				<button class="btn btn-primary js-ajax-submit" type="submit">添加</button>
				<a class="btn" href="javascript:history.back(-1);">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>

	<script type="text/javascript">
		$("form").submit(function(e){
			var title=$.trim($("#title").val());
			var video_url=$.trim($("#video_url").val());
			var series_id={$series_id};

			if(title==""){
				layer.msg("课程名称不能为空",{time:500});
				return;
			}
			if(video_url==""){
				layer.msg("链接地址不能为空",{time:500});
				return;
			}

			$.ajax({
				type: "POST",
				url: "{:U('Course/add_course_post')}",
				data: {title:title,video_url:video_url,series_id:series_id},
				success: function(result) {
					var result=eval("("+result+")");
					if(result.status){
						layer.msg('添加成功',{time:500},function(){
							location.href="__URL__/course_index?series_id="+series_id;
						});
					}else{
						layer.msg(result.message);
					}
				}
			});
			return false;
		});
	</script>
</body>
</html>